/*$("#form-customerInfo-editIntegral").validate({
	rules:{
		integralNumber:{
			required:true,
		},
		integralType:{
			required:true,
		},
	},
	submitHandler:function(form){
		edit();
	}
});*/
$("button[type='submit']").click(function(){
	edit();
})
function edit() {
	var integralNumber = $("input[name='integralNumber']").val();
	var customerId = $("input[name='customerId']").val();
	var integralType = $("input[name='integralType']:checked").val();
	if (!($(".rechargeRadio").is(":checked"))
		&& !($(".deductionRadio").is(":checked"))) {
		$("#integralType-error").css("display", "block");
	} else if ($("#integralNumber").val() == "") {
		$("#integralType-error").css("display", "none");
		$("#integralNumber-error").css("display", "block");
	} else {
		$("#integralType-error").css("display", "none");
		$("#integralType-error").css("display", "none");
		$("button[type='submit']").attr("disabled", true)
		$.ajax({
			cache : true,
			type : "POST",
			url : ctx + "module/customerInfo/saveCustomerIntegralRecord",
			data : {
				"integralNumber" : integralNumber,
				"customerId" : customerId,
				"integralType" : integralType,
			},
			error : function(request) {
				layer.msg("系统错误", "error");
			},
			success : function(data) {
				if (data.msg == "积分不足") {
					parent.layer.msg("积分不足,请重新输入！", {
						icon : 2,
						time : 1000,
						shade : [ 0.1, '#fff' ]
					}, function() {
						$.parentReload();
					});
				} else if (data.msg == "操作成功") {
					parent.layer.msg("操作成功,正在刷新数据请稍后……", {
						icon : 1,
						time : 1000,
						shade : [ 0.1, '#fff' ]
					}, function() {
						$.parentReload();
					});
				}
			}
		})
	}
}


